﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using mfe.bll;

namespace mfe_proj.Forms
{
    public delegate void PhotoInfoFormEventHandler(object sender, PhotoInfoFormEventArgs e);
    public partial class PhotoInfoForm : Form
    {
        public event PhotoInfoFormEventHandler TitleUpdated;
        public string PhotoGuidID;
        Photo photo;

        public PhotoInfoForm()
        {
            InitializeComponent();
        }

        private void PhotoInfoForm_Load(object sender, EventArgs e)
        {
            photo = new Photo(PhotoGuidID);
            txtTitle.Text = photo.Title;
            txtCaption.Text = photo.Caption;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            //save
            photo.Title = txtTitle.Text.Trim();
            photo.Caption = txtCaption.Text.Trim();
            if (photo.Update())
            {
                if (TitleUpdated != null) TitleUpdated(sender, new PhotoInfoFormEventArgs(photo.Title));
                Close();
            }
        }
    }

    public class PhotoInfoFormEventArgs : EventArgs
    {
        private string _Title;
        public string Title { get { return _Title; } set { _Title = value; } }
        public PhotoInfoFormEventArgs(string title) { _Title = title; }
    }
}
